package com.zahb.qadx.ui.activity.topic;

import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.recyclerview.widget.RecyclerView;


import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.githang.statusbar.StatusBarCompat;
import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.data.PieDataSet;
import com.github.mikephil.charting.data.PieEntry;
import com.github.mikephil.charting.formatter.PercentFormatter;
import com.google.gson.Gson;
import com.luck.picture.lib.tools.ToastUtils;
import com.zahb.qadx.R;
import com.zahb.qadx.base.BaseActivity;
import com.zahb.qadx.model.AnswerBean;
import com.zahb.qadx.model.AnswerSheetListBean;
import com.zahb.qadx.model.DailyExaminationQuestionsBean;
import com.zahb.qadx.model.DailyPractice;
import com.zahb.qadx.net.RetrofitService;
import com.zahb.qadx.net.RetrofitStudyTimeService;
import com.zahb.qadx.ui.view.MyDialog;
import com.zahb.qadx.ui.view.PlayDialog;
import com.zahb.qadx.util.Constant;
import com.zahb.qadx.util.Tips;

import org.jetbrains.annotations.NotNull;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;

//原生每日练习
public class DailyPracticeActivity extends BaseActivity implements OnItemChildClickListener {
    @BindView(R.id.recycler_view)
    RecyclerView mRecyclerView;
    @BindView(R.id.the_topic_order)
    TextView theTopicOrder;
    @BindView(R.id.current_qid)
    TextView currentQid;
    @BindView(R.id.on_a_topic)
    TextView onATopic;
    @BindView(R.id.next_question)
    TextView nextQuestion;
    @BindView(R.id.sheet)
    TextView sheet;
    private String mDailyQuestionCount;
    private String mQuesLibIds;
    private String mPracticeId;
    private int mPath;
    private String mId;
    private List<MyMultipleItem> mDatas02;
    public LinearLayoutManager mLayoutManager;
    private String[] mSerialNumber = {"A", "B", "C", "D", "E", "F", "G", "H"};
    private String[] mTheSerialNumber = {"(1) . ", "(2) . ", "(3) . ", "(4) . ", "(5) . ", "(6) . ", "(7) . ", "(8) . ", "(9) . ", "(10) . "};
    // 答题卡
    private MyDialog mMyDialog;
    public RecyclerView mAnswer_sheetr_ecyclerView;
    private BaseSectionQuickAdapter<AnswerSheetListBean, BaseViewHolder> mAdapter;
    private List<AnswerSheetListBean> mExercisesWeeklies;
    AnswerSheetListBean mExercisesWeekly;
    //数据处理
    private List<DailyExaminationQuestionsBean> mDailyExaminationQuestionsBean = new ArrayList<>();
    private MultipleItemAdapter madapter;
    private DailyPractice mDailyPractice = new DailyPractice();//每日每周提交数据
    private PlayDialog mPlayDialog; //答题最后显示
    private PieChart chart;
    private EditText short_answer_editText, topic_selection;
    private BaseQuickAdapter<DailyExaminationQuestionsBean.QuestionOptionListBean, BaseViewHolder> moreAdapter;
    int record = 1;
    private int repeat=-1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mUnbinder = ButterKnife.bind(this);
        navigationInitialization();//导航栏初始化
    }

    //提交页
    private void answerThePage(int answerCorrectly, int wrong, String correct, int totalNumber) {
        View view = getLayoutInflater().inflate(R.layout.answer_the_page_layou, null);
        mPlayDialog = new PlayDialog(getActivity(), 0, 0, view, R.style.dialog);
        TextView total_dialog = view.findViewById(R.id.total_dialog);
        TextView answer_correctly_dialog = view.findViewById(R.id.answer_correctly_dialog);
        TextView correct_dialog = view.findViewById(R.id.correct_dialog);
        Button return_dialog = view.findViewById(R.id.return_dialog);
        Button continue_dialog = view.findViewById(R.id.continue_dialog);
        return_dialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mPlayDialog.dismiss();
                finish();
            }
        });
        continue_dialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mPlayDialog.dismiss();

                currentQid.setText(1 + "");
                //来源 0 每日 1每周 2
                switch (mPath) {
                    case 0:
                        networkDataAcquisition();//每日练习
                        break;
                    case 1:
                        weeklyQuestions(mId);//获取周练习试题
                        break;
                    case 2:
                        tryToGet();//试题获取
                        break;
                }

            }
        });
        total_dialog.setText("整体量:" + totalNumber);
        answer_correctly_dialog.setText("答对题目数量:" + answerCorrectly);
        correct_dialog.setText("正确率:" + correct);
        chart = view.findViewById(R.id.chart1);
        chart.setCenterText(correct);
        chart.setCenterTextColor(getResources().getColor(R.color.blue));
        chart.getDescription().setEnabled(false);
//        chart.setExtraOffsets(5, 10, 5, 5);
        chart.setDragDecelerationFrictionCoef(0.95f);
        chart.setDrawHoleEnabled(true);
        chart.setHoleColor(Color.WHITE);
        chart.setTransparentCircleColor(Color.WHITE);
        chart.setHoleRadius(58f);
        chart.setTransparentCircleRadius(60f);
        chart.setDrawCenterText(true);
        chart.setRotationEnabled(true);
        chart.setHighlightPerTapEnabled(true);
        chart.animateY(1400);
        chart.setEntryLabelColor((R.color.colorAccent));
        chart.setEntryLabelTextSize(12f);
        setData(answerCorrectly, wrong);
        mPlayDialog.show();
    }

    //百分比环形数据
    private void setData(int count, int range) {
        ArrayList<PieEntry> entries = new ArrayList<>();
        entries.add(new PieEntry(count, "正确"));
        entries.add(new PieEntry(range, "错误"));
        PieDataSet dataSet = new PieDataSet(entries, "");

//        dataSet.setDrawValues(false);
        dataSet.setSliceSpace(3f);
        dataSet.setSelectionShift(5f);
        dataSet.setColors(getResources().getColor(R.color.blue), getResources().getColor(R.color.red_ff4500));

        PieData data = new PieData(dataSet);
        data.setValueFormatter(new PercentFormatter(chart));
        data.setValueTextSize(11f);
        data.setValueTextColor(Color.WHITE);
        chart.setData(data);
        // undo all highlights
        chart.highlightValues(null);

        chart.setUsePercentValues(true);
        chart.setDrawEntryLabels(!chart.isDrawEntryLabelsEnabled());
        chart.invalidate();
    }

    //答题卡
    private void answerSheetList() {
        View view = getLayoutInflater().inflate(R.layout.answer_sheet_layout, null);
        mMyDialog = new MyDialog(getActivity(), 0, 0, view, R.style.dialog);
        TextView answer_cancel = view.findViewById(R.id.answer_cancel);
      View  blank=view.findViewById(R.id.blank);
        blank.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mMyDialog.dismiss();
            }
        });
        answer_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mMyDialog.dismiss();
            }
        });
        mAnswer_sheetr_ecyclerView = view.findViewById(R.id.answer_sheetr_ecyclerView);
        mAnswer_sheetr_ecyclerView.setLayoutManager(new GridLayoutManager(this, 5));
        mAnswer_sheetr_ecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
                outRect.set(0, 0, 0, 0);
            }
        });
        mExercisesWeeklies = new ArrayList<>();
        //这里我是随机给某一条目加载不同的布局
        for (int i = 0; i < mDailyExaminationQuestionsBean.size(); i++) {
            // TODO: 2021/5/10  答题卡内容录入
            if (i == 0 || mDailyExaminationQuestionsBean.get(i).getQuestionType() != mDailyExaminationQuestionsBean.get(i - 1).getQuestionType()) {
                mExercisesWeekly = new AnswerSheetListBean();
                mExercisesWeekly.setGrouping(0);
                if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 1) {
                    mExercisesWeekly.setTitle("单选题");
                } else if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 2) {
                    mExercisesWeekly.setTitle("多选题");
                } else if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 3) {
                    mExercisesWeekly.setTitle("判断题");
                } else if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 4) {
                    mExercisesWeekly.setTitle("填空题");
                } else if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 5) {
                    mExercisesWeekly.setTitle("简答题");
                } else if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 6) {
                    mExercisesWeekly.setTitle("案例题");
                }
                mExercisesWeeklies.add(mExercisesWeekly);
            }
            mExercisesWeekly = new AnswerSheetListBean();
            mExercisesWeekly.setQid(i + 1);
            mExercisesWeekly.setGrouping(1);
            mExercisesWeeklies.add(mExercisesWeekly);

        }
        mAdapter = new BaseSectionQuickAdapter<AnswerSheetListBean, BaseViewHolder>(
                R.layout.grouping_layout, R.layout.team_members_layout, mExercisesWeeklies) {
            @Override
            protected void convertHeader(@NotNull BaseViewHolder baseViewHolder, @NotNull AnswerSheetListBean item) {
                TextView text_header = baseViewHolder.findView(R.id.text_header);
                text_header.setText(item.getTitle());
            }

            @Override
            protected void convert(@NotNull BaseViewHolder baseViewHolder, AnswerSheetListBean item) {
                TextView tvName = baseViewHolder.getView(R.id.text_content);
                tvName.setText(item.getQid() + "");
                if (mDailyExaminationQuestionsBean.get(item.getQid() - 1).getTheAnswerState() == 0) {
                    tvName.setBackground(getContext().getResources().getDrawable(R.drawable.grey_circle_360dp));
                } else if (mDailyExaminationQuestionsBean.get(item.getQid() - 1).getTheAnswerState() == 1) {
                    tvName.setBackground(getContext().getResources().getDrawable(R.drawable.the_green_circle));
                } else {
                    tvName.setBackground(getContext().getResources().getDrawable(R.drawable.the_red_circle_360dp));
                }
                tvName.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        controlTheAnswer(mDailyExaminationQuestionsBean.size(), item.getQid(), 1);
                        mMyDialog.dismiss();
                    }
                });
            }
        };
        mAdapter.setOnItemChildClickListener(this);
        mAdapter.addChildClickViewIds(R.id.text_content);
        mAnswer_sheetr_ecyclerView.setAdapter(mAdapter);
    }

    //导航栏初始化
    private void navigationInitialization() {
        StatusBarCompat.setStatusBarColor(this, getResources().getColor(R.color.blue));//状态栏颜色
        mTopBarContainer.setBackgroundColor(getResources().getColor(R.color.blue));//头部布局颜色
        mTitle_view.setTextColor(getResources().getColor(R.color.white));//标题颜色
        Drawable drawable = getResources().getDrawable(R.mipmap.fanhui);//返回箭头
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());// 设置边界
        // param 左上右下
        mTopBarStartText.setCompoundDrawables(drawable, null, null, null);
        mTopBarStartText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    //网络请求 题库每日练习
    private void networkDataAcquisition() {
        addDisposable(RetrofitService.getNetService()
                .getDailyPractice(mDailyQuestionCount, mQuesLibIds)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(response -> {
                    if (response.getStatusCode() == Constant.CODE_SUCCESS) {
                        mDailyExaminationQuestionsBean = new ArrayList<>();
                        mDailyExaminationQuestionsBean = response.getData();
                        processingUnifiedData(mDailyExaminationQuestionsBean);

                    }
                }, throwable -> {
                    throwable.printStackTrace();
                    Tips.RequestError(getActivity());
                }));
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_daily_practice;
    }

    @Override
    protected void initViews() {
        mDailyQuestionCount = getIntent().getStringExtra("dailyQuestionCount");
        mQuesLibIds = getIntent().getStringExtra("quesLibIds");
        mPracticeId = getIntent().getStringExtra("practiceId");
        mPath = getIntent().getExtras().getInt("path");
        mId = getIntent().getStringExtra("id");

        //来源 0 每日 1每周 2
        switch (mPath) {
            case 0:
                networkDataAcquisition();//每日练习
                break;
            case 1:
                weeklyQuestions(mId);//获取周练习试题
                break;
            case 2:
                tryToGet();//试题获取
                break;
        }
    }

    //数据整理
    private void processingUnifiedData(List<DailyExaminationQuestionsBean> mDailyExaminationQuestionsBean) {
        mDatas02 = new ArrayList<>();
        //getQuestionType()根绝重先排序
        Collections.sort(mDailyExaminationQuestionsBean, new Comparator<DailyExaminationQuestionsBean>() {
            @Override
            public int compare(DailyExaminationQuestionsBean dailyExaminationQuestionsBean, DailyExaminationQuestionsBean t1) {
                return dailyExaminationQuestionsBean.getQuestionType() - t1.getQuestionType();
            }
        });
        //这里我是随机给某一条目加载不同的布局
        for (int i = 0; i < mDailyExaminationQuestionsBean.size(); i++) {
            if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 1) {//单选
                mDatas02.add(new MyMultipleItem(MyMultipleItem.FIRST_TYPE, mDailyExaminationQuestionsBean.get(i)));
            } else if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 2) {//多选
                mDatas02.add(new MyMultipleItem(MyMultipleItem.SECOND_TYPE, mDailyExaminationQuestionsBean.get(i)));
            } else if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 3) {//判断
                mDatas02.add(new MyMultipleItem(MyMultipleItem.NORMAL_TYPE, mDailyExaminationQuestionsBean.get(i)));
            } else if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 4) {//填空
                mDatas02.add(new MyMultipleItem(MyMultipleItem.EMPTY_FOUR, mDailyExaminationQuestionsBean.get(i)));
            } else if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 5) {//简答
                mDatas02.add(new MyMultipleItem(MyMultipleItem.JANE_FIVE, mDailyExaminationQuestionsBean.get(i)));
            } else if (mDailyExaminationQuestionsBean.get(i).getQuestionType() == 6) {//案例
//                                mDatas02.add(new MyMultipleItem(MyMultipleItem.NORMAL_TYPE, mDailyExaminationQuestionsBean.get(i)));
            }
        }
        theTopicOrder.setText("/" + mDailyExaminationQuestionsBean.size() + " " + testingTypes(mDailyExaminationQuestionsBean.get(0).getQuestionType()));
        //创建布局管理
        mLayoutManager = new LinearLayoutManager(this);
        mLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        mRecyclerView.setLayoutManager(mLayoutManager);
        //创建适配器
        madapter = new MultipleItemAdapter(mDatas02);
        //给RecyclerView设置适配器
        mRecyclerView.setAdapter(madapter);
        mRecyclerView.setOnFlingListener(null);
        PagerSnapHelper snapHelper = new PagerSnapHelper();
        //加在setAdapter后面
        snapHelper.attachToRecyclerView(mRecyclerView);

        mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);

                if (newState == 0 && mLayoutManager.findFirstCompletelyVisibleItemPosition() != -1) {
                    if (repeat!=mLayoutManager.findFirstCompletelyVisibleItemPosition()){
                        theTopicOrder.setText("/" + mDailyExaminationQuestionsBean.size() + " " + testingTypes(mDailyExaminationQuestionsBean.get(mLayoutManager.findFirstCompletelyVisibleItemPosition()).getQuestionType()));
                        controlTheAnswer(mDailyExaminationQuestionsBean.size(), mLayoutManager.findFirstCompletelyVisibleItemPosition() + 1, 2);
                        repeat=mLayoutManager.findFirstCompletelyVisibleItemPosition();
                    }

                }
            }
        });
    }

    //获取周练习试题
    private void weeklyQuestions(String id) {
        addDisposable(RetrofitService.getNetService()
                .getEveryWeekTry(id)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(response -> {
                    if (response.getStatusCode() == Constant.CODE_SUCCESS) {
                        mDailyExaminationQuestionsBean = response.getData();
                        processingUnifiedData(mDailyExaminationQuestionsBean);
                    } else {

                    }
                }, throwable -> {
                    throwable.printStackTrace();
                    Tips.RequestError(getActivity());
                }));
    }

    //试题获取
    private void tryToGet() {
        addDisposable(RetrofitService.getNetService()
                .getMyTraining(mPracticeId)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(response -> {
                    if (response.getStatusCode() == Constant.CODE_SUCCESS) {
                        mDailyExaminationQuestionsBean = response.getData().getQuestionList();
                        processingUnifiedData(mDailyExaminationQuestionsBean);
                    } else {

                    }
                }, Throwable::printStackTrace));

    }

    @Override
    protected int getTitleStringRes() {
        int title = R.string.daily_practice;
        switch (mPath) {
            case 0:
                title = R.string.daily_practice;
                break;
            case 1:
                title = R.string.dvery_week_to_practice;
                break;
            case 2:
                title = R.string.practice_practice;
                break;
        }

        return title;
    }



    @OnClick({R.id.on_a_topic, R.id.next_question, R.id.sheet})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.on_a_topic://上一题
                if (mLayoutManager.findFirstCompletelyVisibleItemPosition() == 0) {
                    ToastUtils.s(this, "当前是第一道题");
                } else {
                    if (mLayoutManager.findLastCompletelyVisibleItemPosition() == -1) return;
                    controlTheAnswer(mDailyExaminationQuestionsBean.size(), mLayoutManager.findFirstCompletelyVisibleItemPosition(), 1);
                }
                nextQuestion.setText("下一题");
                break;
            case R.id.next_question://下一题
                if (mLayoutManager.findFirstCompletelyVisibleItemPosition() == (mDailyExaminationQuestionsBean.size() - 1)) {
                    ToastUtils.s(this, "已提交");
                    switch (mPath) {
                        case 0:
                            submit(1);
                            break;
                        case 1:
                            submit(2);
                            break;
                        case 2:
                            practiceToSubmit();//去练习记录学时
                            break;
                    }
                } else {
                    if (mLayoutManager.findLastCompletelyVisibleItemPosition() == -1) return;
                    controlTheAnswer(mDailyExaminationQuestionsBean.size(), mLayoutManager.findFirstCompletelyVisibleItemPosition() + 2, 1);

                }
                break;

            case R.id.sheet:
                answerSheetList();//答题卡
                mMyDialog.show_widescreen();
                break;
        }
    }

    //每日每周提交
    private void submit(int type) {
        Gson mGson = new Gson();
        int rightQuestionCount = 0;
        List<DailyPractice.AnswerListDtoListBean> mListAnswerListDtoListBean = new ArrayList<>();

        for (int i = 0; i < mDailyExaminationQuestionsBean.size(); i++) {

            if (mDailyExaminationQuestionsBean.get(i).getTheAnswerState() == 1) {
                rightQuestionCount++;
            }

            DailyPractice.AnswerListDtoListBean mAnswerListDtoListBean = new DailyPractice.AnswerListDtoListBean();
            mAnswerListDtoListBean.setId(mDailyExaminationQuestionsBean.get(i).getId());
            mAnswerListDtoListBean.setIsRight(mDailyExaminationQuestionsBean.get(i).getTheAnswerState());
            mAnswerListDtoListBean.setAnswer(mDailyExaminationQuestionsBean.get(i).getAnswer());
            mListAnswerListDtoListBean.add(mAnswerListDtoListBean);
        }
        mDailyPractice.setType(type);
        mDailyPractice.setRightQuestionCount(rightQuestionCount);
        mDailyPractice.setWrongQuestionCount(mDailyExaminationQuestionsBean.size() - rightQuestionCount);
        if (type==2){
            mDailyPractice.setWeeklyQuestionId(mId);
        }

        mDailyPractice.setAnswerListDtoList(mListAnswerListDtoListBean);
        float pressent = 0;
        if (rightQuestionCount == 0) {
        } else {
            pressent = (float) rightQuestionCount / mDailyExaminationQuestionsBean.size() * 100;//i 增加数量，mBNumber 总数
        }
        DecimalFormat df = new DecimalFormat("#.00");
        String keepTwo = df.format(pressent);
        answerThePage(rightQuestionCount, mDailyExaminationQuestionsBean.size() - rightQuestionCount, keepTwo + "%", mDailyExaminationQuestionsBean.size());//最后答题弹框
        String json1 = mGson.toJson(mDailyPractice);
        RequestBody body = RequestBody.create(MediaType.parse("application/json"), json1);
        addDisposable(RetrofitService.getNetService()
                .dailyAndWeeklySubmissions(body)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(response -> {
                    if (response.getStatusCode() == Constant.CODE_SUCCESS) {

                    }
                }, throwable -> {
                    Tips.RequestError(getActivity());
                    throwable.printStackTrace();
                }));
    }
    //去练习
    private void practiceToSubmit() {
        String json = getIntent().getStringExtra("json");
        RequestBody body = RequestBody.create(MediaType.parse("application/json;charset=UTF-8"), json);
        RetrofitStudyTimeService.sCollectionType = RetrofitStudyTimeService.sCollectionTypeVideo;
        Disposable disposable = RetrofitStudyTimeService.getNetService().saveStudyTime(body)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(response -> {
                    finish();
                }, Throwable::printStackTrace);
        addDisposable(disposable);
    }

    @Override
    public void onItemChildClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
    }

    public class MultipleItemAdapter extends BaseMultiItemQuickAdapter<MyMultipleItem, BaseViewHolder> implements OnItemClickListener {
        public MultipleItemAdapter(List data) {
            super(data);
            //必须绑定type和layout的关系
            addItemType(MyMultipleItem.FIRST_TYPE, R.layout.the_radio);
            addItemType(MyMultipleItem.SECOND_TYPE, R.layout.multi_elect);
            addItemType(MyMultipleItem.NORMAL_TYPE, R.layout.the_radio);
            addItemType(MyMultipleItem.EMPTY_FOUR, R.layout.filiintheblanks_layout);
            addItemType(MyMultipleItem.JANE_FIVE, R.layout.short_answer_layout);
        }

        @Override
        protected void convert(final BaseViewHolder helper, final MyMultipleItem item) {
            switch (helper.getItemViewType()) {
                case MyMultipleItem.FIRST_TYPE:
                    theRadio(helper, item);//单选
                    break;
                case MyMultipleItem.SECOND_TYPE://多选题
                    multiSelect(helper, item);
                    break;
                case MyMultipleItem.NORMAL_TYPE:
                    theRadio(helper, item);//判断
                    break;
                case MyMultipleItem.EMPTY_FOUR://填空
                    fillInTheBlanks(helper, item);
                    break;
                case MyMultipleItem.JANE_FIVE://简答
                    shortAnswer(helper, item);
                    break;
            }
        }

        //单选
        private void theRadio(BaseViewHolder helper, MyMultipleItem<DailyExaminationQuestionsBean> item) {
            final int[] choose = {0};
            WebView topic_of_dry = helper.findView(R.id.topic_of_dry);//题干
            jsSupport(topic_of_dry, item.getData().getContent());
            TextView answer = helper.findView(R.id.answer);//选择答案
            LinearLayout the_analysis_of = helper.findView(R.id.the_analysis_of);//解析答案布局
            TextView correct_answer = helper.findView(R.id.correct_answer);//正确答案
            RecyclerView recyclerView = helper.findView(R.id.answer_list);//选择列表
            TextView check_the_parsing = helper.findView(R.id.check_the_parsing);//查看解析
            recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
            TextView parsing=helper.findView(R.id.parsing);
            parsing.setText(Html.fromHtml(item.getData().getParsing().toString().trim()));

            moreAdapter = new BaseQuickAdapter<DailyExaminationQuestionsBean.QuestionOptionListBean, BaseViewHolder>(R.layout.choose) {
                @Override
                protected void convert(@NotNull BaseViewHolder baseViewHolder, DailyExaminationQuestionsBean.QuestionOptionListBean questionOptionListBean) {
                    TextView topic_selection = baseViewHolder.findView(R.id.topic_selection);
                    ImageView selected = baseViewHolder.findView(R.id.selected);
                    TextView the_order = baseViewHolder.findView(R.id.the_order);
                    answer.setText(item.getData().getSelectedResult());
                    topic_selection.setText(Html.fromHtml(questionOptionListBean.getContent()).toString().trim());
                    final LinearLayout linearLayout = baseViewHolder.findView(R.id.the_whole_article);
                    the_order.setText(questionOptionListBean.getSerialNumber()[baseViewHolder.getAdapterPosition()]);//顺序ABCD
                    if (questionOptionListBean.getIsRightAnswer() == 1) {
                        correct_answer.setText(questionOptionListBean.getSerialNumber()[baseViewHolder.getAdapterPosition()]);
                    }
                    if (choose[0] == 2 || item.getData().getSelectedResult() == "") {
                        assert check_the_parsing != null;
                        check_the_parsing.setVisibility(View.VISIBLE);
                        assert the_analysis_of != null;
                        the_analysis_of.setVisibility(View.GONE);
                    } else {
                        if(the_analysis_of!=null&&check_the_parsing!=null){
                            the_analysis_of.setVisibility(View.VISIBLE);
                            check_the_parsing.setVisibility(View.GONE);
                        }
                    }
                    switch (questionOptionListBean.getStatusValue()) {
                        case 0:
                            topic_selection.setTextColor(getResources().getColor(R.color.colorBlack));
                            the_order.setTextColor(getResources().getColor(R.color.colorBlack));
                            linearLayout.setBackground(getContext().getResources().getDrawable(R.drawable.grey_circle));
                            selected.setVisibility(View.INVISIBLE);

                            break;
                        case 1:
                            topic_selection.setTextColor(getResources().getColor(R.color.blue));
                            the_order.setTextColor(getResources().getColor(R.color.blue));
                            linearLayout.setBackground(getContext().getResources().getDrawable(R.drawable.asingleframe));
                            selected.setVisibility(View.VISIBLE);
                            if (questionOptionListBean.getIsRightAnswer() == 0) {
                                answer.setTextColor(getResources().getColor(R.color.red_ff4500));
                                item.getData().setTheAnswerState(2);
                            } else {
                                answer.setTextColor(getResources().getColor(R.color.blue));
                                item.getData().setTheAnswerState(1);
                            }
                            break;
                    }
                    linearLayout.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (check_the_parsing.getVisibility() == View.VISIBLE) {
                                for (int i = 0; i < item.getData().getQuestionOptionList().size(); i++) {
                                    if (i == baseViewHolder.getAdapterPosition()) {
                                        questionOptionListBean.setStatusValue(1);
                                        item.getData().setSelectedResult(mSerialNumber[i]);//已选择答案
                                        AnswerBean answerBean = new AnswerBean();
                                        answerBean.setId(questionOptionListBean.getId());
                                        answerBean.setContent(questionOptionListBean.getContent());
                                        List<AnswerBean> answerBeanList = new ArrayList<>();
                                        answerBeanList.add(answerBean);
                                        item.getData().setAnswer(answerBeanList);
                                    } else {
                                        item.getData().getQuestionOptionList().get(i).setStatusValue(0);
                                    }
                                }
                                choose[0] = 2;
                                recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
                                moreAdapter.notifyDataSetChanged();
                            }
                        }
                    });
                    check_the_parsing.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (item.getData().getSelectedResult().equals("")) {
                                showBindToast("请选择答案");
                            } else {
                                choose[0] = 0;
                                check_the_parsing.setVisibility(View.GONE);
                                recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
                                moreAdapter.notifyDataSetChanged();
                            }
                        }
                    });
                }
            };
            moreAdapter.addData(item.getData().getQuestionOptionList());
            moreAdapter.setOnItemClickListener(this);
            recyclerView.setAdapter(moreAdapter);
        }

        //多选
        private void multiSelect(BaseViewHolder helper, MyMultipleItem<DailyExaminationQuestionsBean> item) {
            final int[] choose = {0};
            //多选题
            WebView more_topic_of_dry;//题干
            RecyclerView more_answer_list;//选题列表
            TextView more_answer;//最终选择结果
            TextView more_correct_answer;
            more_topic_of_dry = helper.findView(R.id.more_topic_of_dry);
            jsSupport(more_topic_of_dry, item.getData().getContent());
            more_answer_list = helper.findView(R.id.more_answer_list);//选题列表
            more_answer_list.setLayoutManager(new LinearLayoutManager(getContext()));
            more_answer = helper.findView(R.id.more_answer);//多选结果
            TextView check_the_parsing = helper.findView(R.id.check_the_parsing);//查看解析
            LinearLayout more_the_analysis_of = helper.findView(R.id.more_the_analysis_of);//解析答案布局
            more_correct_answer = helper.findView(R.id.more_correct_answer);
            TextView more_parsing=helper.findView(R.id.more_parsing);//解析
            more_parsing.setText(Html.fromHtml(item.getData().getParsing().toString().trim()));
            moreAdapter = new BaseQuickAdapter<DailyExaminationQuestionsBean.QuestionOptionListBean, BaseViewHolder>(R.layout.choose) {
                @Override
                protected void convert(@NotNull BaseViewHolder baseViewHolder, DailyExaminationQuestionsBean.QuestionOptionListBean more_questionOptionListBean) {
                    TextView topic_selection = baseViewHolder.findView(R.id.topic_selection);//选项内容
                    ImageView selected = baseViewHolder.findView(R.id.selected);//对号
                    TextView the_order = baseViewHolder.findView(R.id.the_order);//序列号
                    topic_selection.setText(Html.fromHtml(more_questionOptionListBean.getContent()).toString().trim());
                    final LinearLayout linearLayout = baseViewHolder.findView(R.id.the_whole_article);
                    the_order.setText(more_questionOptionListBean.getSerialNumber()[baseViewHolder.getAdapterPosition()]);//顺序ABCD
                    String refer_to_the_answer = "";
                    for (int i = 0; i < item.getData().getQuestionOptionList().size(); i++) {
                        if (item.getData().getQuestionOptionList().get(i).getIsRightAnswer() == 1) {
                            refer_to_the_answer = refer_to_the_answer + mSerialNumber[i];
                        }
                    }



                    more_answer.setText(item.getData().getSelectedResult());
                    item.getData().setRefer_to_the_answer(refer_to_the_answer);
                    more_correct_answer.setText(item.getData().getRefer_to_the_answer());
                    if (item.getData().getSelection_state() == 1) {


                        if (item.getData().getRefer_to_the_answer().equals(item.getData().getSelectedResult())) {
                            more_answer.setTextColor(getResources().getColor(R.color.blue));
                            item.getData().setTheAnswerState(1);
                        } else {
                            more_answer.setTextColor(getResources().getColor(R.color.red_ff4500));
                            item.getData().setTheAnswerState(2);
                        }
                    }


                    if (choose[0] == 2 || item.getData().getSelectedResult() == "") {
                        check_the_parsing.setVisibility(View.VISIBLE);
                        more_the_analysis_of.setVisibility(View.GONE);
                    } else {
                        more_the_analysis_of.setVisibility(View.VISIBLE);
                        check_the_parsing.setVisibility(View.GONE);
                    }


                    switch (more_questionOptionListBean.getStatusValue()) {
                        case 0:
                            topic_selection.setTextColor(getResources().getColor(R.color.colorBlack));
                            the_order.setTextColor(getResources().getColor(R.color.colorBlack));
                            linearLayout.setBackground(getContext().getResources().getDrawable(R.drawable.grey_circle));
                            selected.setVisibility(View.INVISIBLE);
                            break;
                        case 1:
                            topic_selection.setTextColor(getResources().getColor(R.color.blue));
                            the_order.setTextColor(getResources().getColor(R.color.blue));
                            linearLayout.setBackground(getContext().getResources().getDrawable(R.drawable.asingleframe));
                            selected.setVisibility(View.VISIBLE);

                            break;

                    }
                    //多选择
                    linearLayout.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (check_the_parsing.getVisibility() == View.VISIBLE) {
                                choose[0] = 2;
                                if (more_questionOptionListBean.getStatusValue() == 0) {
                                    more_questionOptionListBean.setStatusValue(1);
                                } else {
                                    more_questionOptionListBean.setStatusValue(0);
                                }
                                List<AnswerBean> answer = new ArrayList<>();
                                String results = "";
                                for (int i = 0; i < item.getData().getQuestionOptionList().size(); i++) {
                                    if (item.getData().getQuestionOptionList().get(i).getStatusValue() == 1) {
                                        results = results + mSerialNumber[i];
                                        item.getData().setSelectedResult(results);//已选择答案
                                        AnswerBean answerBean = new AnswerBean();
                                        answerBean.setId(item.getData().getQuestionOptionList().get(i).getId());
                                        answerBean.setContent(item.getData().getQuestionOptionList().get(i).getContent());
                                        answer.add(answerBean);//获取答完 id 和选项题
                                    }
                                }
                                item.getData().setAnswer(answer);
                                item.getData().setSelection_state(1);
                                more_answer_list.setLayoutManager(new LinearLayoutManager(getContext()));
                                moreAdapter.notifyDataSetChanged();
                            }
                        }
                    });
                    //提交选择结果
                    check_the_parsing.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (item.getData().getSelectedResult() == ""){

                                    showBindToast("请选择答案");
                               return;
                            }
                            choose[0] = 0;
                            more_answer_list.setLayoutManager(new LinearLayoutManager(getContext()));
                            moreAdapter.notifyDataSetChanged();

                        }
                    });
                }
            };
            moreAdapter.addData(item.getData().getQuestionOptionList());
            moreAdapter.setOnItemClickListener(this);
            more_answer_list.setAdapter(moreAdapter);
        }

        //填空
        private void fillInTheBlanks(BaseViewHolder helper, MyMultipleItem<DailyExaminationQuestionsBean> item) {
            final int[] choose = {0};
            WebView empty_topic_of_dry = helper.findView(R.id.empty_topic_of_dry);
            TextView empty_correct_answer = helper.findView(R.id.empty_correct_answer);
            RecyclerView empty_answer_list = helper.findView(R.id.empty_answer_list);
            TextView empty_answer = helper.findView(R.id.empty_answer);
            jsSupport(empty_topic_of_dry, item.getData().getContent());
            LinearLayout empty_the_analysis_of = helper.findView(R.id.empty_the_analysis_of);
            TextView check_the_parsing = helper.findView(R.id.check_the_parsing);
            empty_answer_list.setLayoutManager(new LinearLayoutManager(getContext()));
            TextView parsing=helper.findView(R.id.parsing);
            parsing.setText(Html.fromHtml(item.getData().getParsing().toString().trim()));

            moreAdapter = new BaseQuickAdapter<DailyExaminationQuestionsBean.QuestionOptionListBean, BaseViewHolder>(R.layout.fill_in_the_empty_layout) {
                @Override
                protected void convert(@NotNull BaseViewHolder baseViewHolder, DailyExaminationQuestionsBean.QuestionOptionListBean questionOptionListBean) {
                    TextView the_order = baseViewHolder.findView(R.id.the_order);
                    topic_selection = baseViewHolder.findView(R.id.topic_selection);
                    empty_answer.setText(item.getData().getSelectedResult());
                    if (choose[0] == 2 || questionOptionListBean.getFillInTheBlanks().length()<1) {
                        check_the_parsing.setVisibility(View.VISIBLE);
                        topic_selection.setFocusable(true);
                        empty_the_analysis_of.setVisibility(View.GONE);
                    } else {
                        item.getData().setSelection_state(1);

                    }
                    if (item.getData().getSelection_state() == 1) {
                        empty_the_analysis_of.setVisibility(View.VISIBLE);
                        check_the_parsing.setVisibility(View.GONE);
                        topic_selection.setFocusable(false);
                        empty_correct_answer.setText(item.getData().getRefer_to_the_answer());
                        if (item.getData().getSelectedResult().equals(item.getData().getRefer_to_the_answer())) {
                            empty_answer.setTextColor(getResources().getColor(R.color.blue));
                            item.getData().setTheAnswerState(1);
                        } else {
                            empty_answer.setTextColor(getResources().getColor(R.color.red_ff4500));
                            item.getData().setTheAnswerState(2);
                        }
                    }

                    the_order.setText(mTheSerialNumber[baseViewHolder.getAdapterPosition()]);
                    topic_selection.setText(questionOptionListBean.getFillInTheBlanks());
                    if (item.getData().getDetermineTheResults().length()>1) {
                        topic_selection.setFocusable(false);
                        Log.e("多少",item.getData().getSelectedResult());

                    } else {
                        topic_selection.setFocusable(true);

                    }
//
                    topic_selection.addTextChangedListener(new TextWatcher() {
                        @Override
                        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                        }

                        @Override
                        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                        }

                        @Override
                        public void afterTextChanged(Editable editable) {

                            questionOptionListBean.setFillInTheBlanks(editable.toString().trim());
                            questionOptionListBean.setFillInTheBlanks_Show(mTheSerialNumber[baseViewHolder.getAdapterPosition()] + editable.toString().trim());
                            choose[0] = 2;
                            List<AnswerBean> answer = new ArrayList<>();
                            String receive = "";
                            String receive_show = "";
                            String determineTheResults = "";
                            for (int i = 0; i < item.getData().getQuestionOptionList().size(); i++) {
                                receive = receive + mTheSerialNumber[i] + item.getData().getQuestionOptionList().get(i).getContent();

                                if (item.getData().getQuestionOptionList().get(i).getFillInTheBlanks_Show() != null && item.getData().getQuestionOptionList().get(i).getFillInTheBlanks_Show() != "") {
                                    receive_show = receive_show + item.getData().getQuestionOptionList().get(i).getFillInTheBlanks_Show();
                                    determineTheResults=determineTheResults+item.getData().getQuestionOptionList().get(i).getFillInTheBlanks();
                                }

                                AnswerBean answerBean = new AnswerBean();
                                answerBean.setId(item.getData().getQuestionOptionList().get(i).getId());
                                answerBean.setContent(item.getData().getQuestionOptionList().get(i).getContent());
                                answer.add(answerBean);//获取答完 id 和选项题
                            }
                            item.getData().setAnswer(answer);
                            item.getData().setSelectedResult(receive_show);//
                            item.getData().setDetermineTheResults(determineTheResults);//
                            item.getData().setRefer_to_the_answer(receive);//参考答案
                        }

                    });
                }
            };
            check_the_parsing.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    choose[0] = 0;
                    madapter.notifyDataSetChanged();
                    if (item.getData().getSelectedResult().length()<1){
                        showBindToast("请选择答案");
                        return;
                    }

                }
            });
            moreAdapter.addData(item.getData().getQuestionOptionList());
            moreAdapter.setOnItemClickListener(this);
            empty_answer_list.setAdapter(moreAdapter);
        }

        //简答
        private void shortAnswer(BaseViewHolder helper, MyMultipleItem<DailyExaminationQuestionsBean> item) {
            WebView short_answer_topic_of_dry = helper.findView(R.id.short_answer_topic_of_dry);
            jsSupport(short_answer_topic_of_dry, item.getData().getContent());
            TextView short_answer_correct_answer = helper.findView(R.id.short_answer_correct_answer);//参考答案
            TextView short_answer_answer = helper.findView(R.id.short_answer_answer);//作答结果
            short_answer_correct_answer.setText(Html.fromHtml(item.getData().getQuestionOptionList().get(0).getContent().trim()));
            LinearLayout the_analysis_of = helper.findView(R.id.the_analysis_of);
            TextView parsing=helper.findView(R.id.parsing);
            parsing.setText(Html.fromHtml(item.getData().getParsing().toString().trim()));
            short_answer_editText = helper.findView(R.id.short_answer_editText);//输入框
            TextView check_the_parsing = helper.findView(R.id.check_the_parsing);//查看解析
            if (item.getData().getSelectedResult().equals("")) {
                the_analysis_of.setVisibility(View.GONE);
                short_answer_editText.setFocusable(true);
                check_the_parsing.setVisibility(View.VISIBLE);
                item.getData().setTheAnswerState(0);
            } else {
                short_answer_answer.setText(item.getData().getSelectedResult());
                short_answer_editText.setText(item.getData().getSelectedResult());
                the_analysis_of.setVisibility(View.VISIBLE);
                short_answer_editText.setFocusable(false);
                item.getData().setTheAnswerState(1);
                check_the_parsing.setVisibility(View.GONE);
            }
            check_the_parsing.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (item.getData().getSelectedResult().length()<1){
                        showBindToast("请选择答案");
                        return;
                    }
                    madapter.notifyDataSetChanged();//最外层的
                }
            });
            short_answer_editText.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                }

                @Override
                public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                }

                @Override
                public void afterTextChanged(Editable editable) {
                    item.getData().setSelectedResult(editable.toString());
                    AnswerBean answerBean = new AnswerBean();
                    answerBean.setId(item.getData().getQuestionOptionList().get(0).getId());
                    answerBean.setContent(item.getData().getQuestionOptionList().get(0).getContent());
                    List<AnswerBean> answerBeanList = new ArrayList<>();
                    answerBeanList.add(answerBean);
                    item.getData().setAnswer(answerBeanList);
                    item.getData().setTheAnswerState(1);
                }
            });
        }

        @Override
        public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        }

    }

    // WebView 权限
    public void jsSupport(WebView webView, String data) {

        WebSettings webSettings = webView.getSettings();

        webSettings.setUseWideViewPort(true);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setUseWideViewPort(true);  //将图片调整到适合webview的大小
        webSettings.setTextZoom(270);//设置H5页面中字体大小不跟随手机系统

//        if (Build.VERSION.SDK_INT >= 19) {
//            //webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);//加载缓存否则网络
//            webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);//不加载缓存
//        }
//
//        if (Build.VERSION.SDK_INT >= 19) {
//            webSettings.setLoadsImagesAutomatically(true);//图片自动缩放 打开
//        } else {
//            webSettings.setLoadsImagesAutomatically(false);//图片自动缩放 关闭
//        }
//
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
//            webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);//软件解码
//        }
//        webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);//硬件解码
//
//        webSettings.setJavaScriptEnabled(true); // 设置支持javascript脚本
//        webSettings.setSupportZoom(true);// 设置可以支持缩放
//        webSettings.setBuiltInZoomControls(true);// 设置出现缩放工具 是否使用WebView内置的缩放组件，由浮动在窗口上的缩放控制和手势缩放控制组成，默认false
//
//        webSettings.setDisplayZoomControls(false);//隐藏缩放工具
//        webSettings.setUseWideViewPort(true);// 扩大比例的缩放
//
//        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);//自适应屏幕
//        webSettings.setLoadWithOverviewMode(true);
//
//        webSettings.setDatabaseEnabled(true);//
//        webSettings.setSavePassword(true);//保存密码
//        webSettings.setDomStorageEnabled(true);//是否开启本地DOM存储  鉴于它的安全特性（任何人都能读取到它，尽管有相应的限制，将敏感数据存储在这里依然不是明智之举），Android 默认是关闭该功能的。
//        webView.setSaveEnabled(true);
//        webView.setKeepScreenOn(true);


        webView.setBackgroundColor(0);
//        ImgStr.getWebview(webView,this,ImgStr.getImgStr(data));
        webView.loadDataWithBaseURL(null,  ImgStr.getImgStr(data), "text/html", "utf-8", null);


    }
    // 题控制
    private void controlTheAnswer(int allAnswer, int current, int address) {
        hideInput();//隐藏软键盘
        if (address == 2) {
            madapter.notifyItemChanged(record - 1);
            record = current;
        }

        if (short_answer_editText != null) {
            short_answer_editText.clearFocus();
        }
        if (topic_selection != null) {
            topic_selection.clearFocus();
        }
        currentQid.setText(current + "");
        if (current == 1) {
            onATopic.setVisibility(View.INVISIBLE);
        } else {
            onATopic.setVisibility(View.VISIBLE);
        }

        if (current == allAnswer) {
            nextQuestion.setText("完成");
        } else {
            nextQuestion.setText("下一题");
        }
        if (mLayoutManager.findFirstCompletelyVisibleItemPosition() - current > 5 || current - mLayoutManager.findFirstCompletelyVisibleItemPosition() > 5) {
            mRecyclerView.scrollToPosition(current - 1);
            madapter.notifyItemChanged(record - 1);
            record = current;
            theTopicOrder.setText("/" + mDailyExaminationQuestionsBean.size() + " " + testingTypes(mDailyExaminationQuestionsBean.get(current - 1).getQuestionType()));
        } else {
            if (address == 1) {
                mRecyclerView.smoothScrollToPosition(current - 1);
            }
        }
    }

    /**
     * 隐藏键盘
     */
    protected void hideInput() {
        InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
        View v = getWindow().peekDecorView();
        if (null != v) {
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }

    }
    //类型分类
    private String testingTypes(int questionType) {
        switch (questionType) {
            case 1:
                return "单选题";
            case 2:
                return "多选题";
            case 3:
                return "判断题";
            case 4:
                return "填空题";
            case 5:
                return "简答题";
            case 6:
                return "案例题";

        }
        return "试题";
    }
}
